package com.bush.mall.coupon.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.coupon.entity.HomeSubjectSpuEntity;
import com.bush.mall.coupon.service.HomeSubjectSpuService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 专题商品
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("homesubjectspu")
@Api(tags = "专题商品管理" )
public class HomeSubjectSpuController {

    @Resource(name= HomeSubjectSpuService.BEAN_ID)
    private HomeSubjectSpuService homeSubjectSpuService;

    /**
     * 分页查询专题商品列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询专题商品列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return homeSubjectSpuService.queryForPage(current,size);
    }

    /**
     * 保存专题商品表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存专题商品表单")
    @PostMapping
    public Result saveHomeSubjectSpu(@RequestBody HomeSubjectSpuEntity homeSubjectSpu){
        return homeSubjectSpuService.saveHomeSubjectSpu(homeSubjectSpu);
    }

    /**
     * 修改专题商品表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改专题商品表单")
    @PutMapping
    public Result updateHomeSubjectSpu(@RequestBody HomeSubjectSpuEntity homeSubjectSpu){
        return homeSubjectSpuService.updateHomeSubjectSpu(homeSubjectSpu);
    }

    /**
     * 通过指定id删除专题商品
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除专题商品")
    @DeleteMapping
    public Result deleteHomeSubjectSpu(Long id){
        return homeSubjectSpuService.deleteHomeSubjectSpu(id);
    }

}
